﻿//-----------------------------------------------------------------------
// <copyright file="PublishedException.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics.Silverlight
{
    using System;

    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    
    using System.Globalization;

    using System.Runtime.Serialization;

    using System.Security;
    using System.Security.Permissions;

    /// <summary>
    /// Indicates that the <see cref="M:CodePlex.Diagnostics.PublishedException.InnerException"/> was published.
    /// </summary>
    public sealed class PublishedException : Exception, IPublishedException
    {
        #region public PublishedException()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:PublishedException"/> class.
        /// </summary>
        public PublishedException()
        {
        }

        #endregion

        #region public PublishedException(string message)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:PublishedException"/> class.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        public PublishedException(string message) : base(message)
        {
        }

        #endregion

        #region public PublishedException(string message, Exception innerException) : base(message, innerException)

        /// <summary>
        /// Initializes a new instance of the <see cref="PublishedException"/> class.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a <c>null</c> reference (Nothing in Visual Basic) if no inner exception is specified.</param>
        public PublishedException(string message, Exception innerException) : base(message, innerException)
        {
        }

        #endregion

        #region public PublishedException(Guid publicationId, Exception ex) : base(string.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PublishedException), ex.GetType().ToString()), ex)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:PublishedException"/> class with the specified detailed description and the specified exception. 
        /// </summary>
        /// <param name="publicationId">The publication identifier of the inner exception.</param>
        /// <param name="ex">A reference to the inner exception that is the cause of this exception.</param>
        public PublishedException(Guid publicationId, Exception ex) : base(string.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PublishedException), ex.GetType().ToString()), ex)
        {
            this.PublicationId = publicationId;
        }

        #endregion

        #region public Guid PublicationId

        /// <summary>
        /// Gets the publication Id associated with the <see cref="M:System.Exception.InnerException"/>.
        /// </summary>
        public Guid PublicationId
        {
            get;
            private set;
        }

        #endregion
    }
}

